package 品牌管理;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class 修改 {
    public static void main(String[] args) {
        String url = "jdbc:mysql://localhost:3306/db_jdbc_demo?characterEncoding=utf8&useSSL=false&serverTimezone=UTC";
        String user = "root";
        String pass = "xiaotong123";
        Connection conn = null;
        PreparedStatement pstmt = null;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            conn = DriverManager.getConnection(url, user, pass);
            String sql = " update t_brand\n" + " set brand_name = ?,\n" + " company_name= ?,\n" + " ordered = ?,\n" + " description = ?,\n" + " status = ?\n" + " where id = ?";
            pstmt = conn.prepareStatement(sql);
            pstmt.setString(1,"122");
            pstmt.setString(2,"22");
            pstmt.setInt(3,100);
            pstmt.setString(4,"333");
            pstmt.setInt(5,1);
            pstmt.setInt(6,6);
            int i = pstmt.executeUpdate();
            if (i == 1) {
                System.out.println("修改成功");
            } else {
                System.out.println("修改失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                pstmt.close();
                conn.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }

        }
    }
}
